 $().ready(function(){
 	$("a[name = 'loginhref']").unbind("click");
	$("a[name = 'loginhref']").bind("click", function() {
		login();
		//alert($("select[name='secondinst']").find("option:selected").text());
	});   
 });


 function login(){
 	var clerkname = $("input[name = 'textfield']").val();
 	var password = $("input[name = 'textfield2']").val();

 	if (clerkname == "" || password == "") {
 		alert("登录名或密码不能为空！！！");
 	} else {
 		var logininfo = {
 			"clerkname" : clerkname,
 			"clerkpassword" : password
 		};

	 	$.ajax({
	        url:"http://localhost/PersonManSystem/humanresource/login.action",
	        type:"get",
	        dataType:'json',
	        contentType:'application/json;charset=utf-8',
	        //data:JSON.stringify(schoolBannerInfo),
	       	data:logininfo,//get方式
	       	//data:null,
	        success:function(data){
	        	if (data['code'] == 404) {
	        		alert("用户名或密码错误");
	        	} else {
	        		sessionStorage.setItem("loginclerkname", data['data']['clerkname']);
	        		sessionStorage.setItem("photopath", data['data']['clerkphotopath']);
	        		window.location='index.htm';
	        	}
	        },
	        error:function(XMLHttpRequest, textStatus, errorThrown){  
	          	alert("Error");  
	         	alert(XMLHttpRequest.status);  
	          	alert(XMLHttpRequest.readyState);  
	          	alert(textStatus); 
	        }
	  	});   
	 }
 }